package cn.glutnn.dao;

import java.util.List;

import cn.glutnn.entity.Seat;
import cn.glutnn.util.JdbcUtils;

public class SeatDao {

	public boolean save(List<Seat> list) {

		boolean isOK = true;

		for (Seat seat : list) {
			boolean isThisOK = JdbcUtils.save(seat);

			isOK = isOK && isThisOK;
		}

		return isOK;
	}

	public List<Seat> findByRoomid(Integer id) {
		String sql = "select * from t_seat where roomid = " + id;
		
		List<Seat> list = JdbcUtils.query(sql, Seat.class);
		return list;
	}
	
	public Seat findOneByRoomidAndCode(Integer roomid, String code) {
		String sql = "select * from t_seat where roomid = " + roomid + " and code = '"+code+"'";
		return JdbcUtils.queryOne(sql, Seat.class);
	}

	public boolean delete(Integer id) {
		return JdbcUtils.delete(id, Seat.class);
	}

	public boolean update(Seat seat) {
		return JdbcUtils.update(seat);
	}

}
